package main

import (
	"flag"
	"fmt"
	"math/rand"
	"time"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/dynamodb"
	"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
)

func init() {
	rand.Seed(time.Now().UTC().UnixNano())
}

type puppy struct {
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	Age            float64 `json:"age"`
	Weight         string  `json:"weight"`
	PrimaryColor   string  `json:"primaryColor"`
	SecondaryColor string  `json:"secondaryColor"`
	Owner          string  `json:"owner"`
	Location       string  `json:"location"`
	Motto          string  `json:"motto"`
	Breed          string  `json:"breed"`
}

func main() {
	tableName := flag.String("table-name", "", "Table Name is the name of the table to seed with data")
	flag.Parse()
	if tableName == nil {
		panic("no table name given")
	}

	var (
		N                = 100
		p                *puppy
		puppyMaxIndex    = len(puppyNames)
		humanMaxIndex    = len(humanNames)
		colorMaxIndex    = len(colors)
		locationMaxIndex = len(locations)
		breedMaxIndex    = len(breeds)
		maxWeight        = 40
		maxAge           = 20
	)
	session := session.Must(session.NewSession(&aws.Config{Region: aws.String("us-east-1")}))
	svc := dynamodb.New(session)

	for N > 0 {
		p = &puppy{
			Name:           puppyNames[rand.Intn(puppyMaxIndex)],
			PrimaryColor:   colors[rand.Intn(colorMaxIndex)],
			SecondaryColor: colors[rand.Intn(colorMaxIndex)],
			Owner:          humanNames[rand.Intn(humanMaxIndex)],
			Location:       locations[rand.Intn(locationMaxIndex)],
			Weight:         fmt.Sprintf("%dlb", rand.Intn(maxWeight)+2),
			Motto:          "Woof Woof!",
			Age:            float64(rand.Intn(maxAge)),
			Breed:          breeds[rand.Intn(breedMaxIndex)],
		}

		p.ID = uuid.NewV4().String()

		avm, err := dynamodbattribute.MarshalMap(p)
		if err != nil {
			fmt.Println(err.Error())
		} else {
			_, err := svc.PutItem(&dynamodb.PutItemInput{
				Item:      avm,
				TableName: aws.String("puppies"),
			})
			if err != nil {
				fmt.Println(err.Error())
			}
		}
		N--
	}
}

var colors = []string{"white", "black", "red", "golden", "black", "brown"}
var humanNames = []string{"Hannelore Croswell",
	"Grazyna Keep",
	"Edison Sterrett",
	"Darby Paxton",
	"Meagan Tope",
	"Alonso Bourassa",
	"Malika Province",
	"Penni Heeren",
	"Pamula Nealey",
	"Janette Vanderwal",
	"Kourtney Backman",
	"Thea Cathcart",
	"Annie Vanscyoc",
	"Alene Hillman",
	"Wen Ardis",
	"Candance Bohlen",
	"Elidia Delosreyes",
	"Octavio Byford",
	"Donetta Lake",
	"Eufemia Kwak",
	"Treena Bona",
	"Lennie Crowl",
	"Tomasa Bonnie",
	"Aisha Hensel",
	"Shakia Releford",
	"Artie Eubanks",
	"Celsa Xie",
	"Camie Santore",
	"Fransisca Nourse",
	"Palmer Czapla",
	"Eneida Thor",
	"Antony Wolpert",
	"Pandora Binns",
	"Nickie Foti",
	"Ty Hasbrouck",
	"Alexandria Varnadoe",
	"Tim Amaro",
	"Arnoldo Daugherty",
	"Gwyn Schutz",
	"Kenneth Nowlen",
	"Isadora Plotkin",
	"Daniele Chenault",
	"Megan Hammons",
	"Pennie Shilling",
	"Holly Capers",
	"Paige Swinton",
	"Brianne Mean",
	"Bonita Braud",
	"Hassie Jarrells",
	"Randa Schmid"}
var puppyNames = []string{"Max", "Bella", "Charlie",
	"Lucy",
	"Cooper",
	"Daisy",
	"Buddy",
	"Luna",
	"Jack",
	"Lola",
	"Rocky",
	"Sadie",
	"Bear",
	"Molly",
	"Tucker",
	"Bailey",
	"Oliver",
	"Maggie",
	"Duke",
	"Sophie",
	"Toby",
	"Chloe",
	"Bentley",
	"Stella",
	"Milo",
	"Lily",
	"Teddy",
	"Penny",
	"Leo",
	"Zoey",
	"Winston",
	"Coco",
	"Jax",
	"Roxy",
	"Zeus",
	"Gracie",
	"Louie",
	"Mia",
	"Murphy",
	"Nala",
	"Jake",
	"Ruby",
	"Dexter",
	"Rosie",
	"Riley",
	"Ellie",
	"Gus",
	"Abby",
	"Buster",
	"Zoe",
	"Harley",
	"Piper",
	"Bailey",
	"Ginger",
	"Jackson",
	"Lilly",
	"Henry",
	"Lulu",
	"Ollie",
	"Riley",
	"Oscar",
	"Sasha",
	"Finn",
	"Lexi",
	"Lucky",
	"Pepper",
	"Moose",
	"Emma",
	"Hank",
	"Layla",
	"Baxter",
	"Maya",
	"Bruno",
	"Izzy",
	"Diesel",
	"Lady",
	"Loki",
	"Annie",
	"Sam",
	"Olive",
	"Cody",
	"Harley",
	"Beau",
	"Belle",
	"Bandit",
	"Dixie",
	"Blue",
	"Millie",
	"Jasper",
	"Willow",
	"Apollo",
	"Princess",
	"Ace",
	"Charlie",
	"Sammy",
	"Maddie",
	"Thor",
	"Kona",
	"Gunner",
	"Cali",
	"Gizmo",
	"Ella",
	"Koda",
	"Winnie",
	"Shadow",
	"Roxie",
	"Scout",
	"Marley",
	"Brody",
	"Cookie",
	"Bo",
	"Hazel",
	"Marley",
	"Scout",
	"Simba",
	"Athena",
	"Roscoe",
	"Callie",
	"Otis",
	"Phoebe",
	"Rocco",
	"Honey",
	"Rex",
	"Angel",
	"George",
	"Dakota",
	"Hunter",
	"Minnie",
	"Tank",
	"Holly",
	"Luke",
	"Missy",
	"Ziggy",
	"Sugar",
	"Maverick",
	"Shelby",
	"Rusty",
	"Nova",
	"Boomer",
	"Leia",
	"Romeo",
	"Josie",
	"Tyson",
	"Penelope",
	"Chance",
	"Ava",
	"Benny",
	"Gigi",
	"Ranger",
	"Peanut",
	"Prince",
	"Fiona",
	"Oreo",
	"Cleo",
	"Bruce",
	"Jasmine",
	"Copper",
	"Sandy",
	"Benji",
	"Mocha",
	"Joey",
	"Harper",
	"Rudy",
	"Macy",
	"Samson",
	"Sydney",
	"Cash",
	"Paisley",
	"Peanut",
	"Lacey",
	"Frankie",
	"Bonnie",
	"Kobe",
	"Baby",
	"Coco",
	"Mila",
	"Chewy",
	"Delilah",
	"Chico",
	"Pearl",
	"Chase",
	"Charlotte",
	"Zeke",
	"Trixie",
	"King",
	"Ivy",
	"Chester",
	"Nina",
	"Odin",
	"Heidi",
	"Walter",
	"Georgia",
	"Brady",
	"Shadow",
	"Brutus",
	"Xena",
	"Mickey",
	"Allie",
	"Mac",
	"Oreo"}

var locations = []string{"Alabama",
	"Alaska",
	"Arizona",
	"Arkansas",
	"California",
	"Colorado",
	"Connecticut",
	"Delaware",
	"Florida",
	"Georgia",
	"Hawaii",
	"Idaho",
	"Illinois",
	"Indiana",
	"Iowa",
	"Kansas",
	"Kentucky",
	"Louisiana",
	"Maine",
	"Maryland",
	"Massachusetts",
	"Michigan",
	"Minnesota",
	"Mississippi",
	"Missouri",
	"Montana",
	"Nebraska",
	"Nevada",
	"New Hampshire",
	"New Jersey",
	"New Mexico",
	"New York",
	"North Carolina",
	"North Dakota",
	"Ohio",
	"Oklahoma",
	"Oregon",
	"Pennsylvania",
	"Rhode Island",
	"South Carolina",
	"South Dakota",
	"Tennessee",
	"Texas",
	"Utah",
	"Vermont",
	"Virginia",
	"Washington",
	"West Virginia",
	"Wisconsin",
	"Wyoming"}

var breeds = []string{"Affenpinscher",
	"Afghan Hound",
	"Airedale Terrier",
	"Alaskan Malamute",
	"American Staffordshire Bull Terrier",
	"Anatolian Shepherd Dog",
	"Australian Cattle Dog",
	"Australian Kelpie",
	"Australian Shepherd Dog",
	"Australian Silky Terrier",
	"Australian Terrier",
	"Basenji",
	"Basset Fauve de Bretagne",
	"Basset Hound",
	"Beagle",
	"Bearded Collie",
	"Bedlington Terrier",
	"Belgian Shepherd Dog Groenendael",
	"Belgian Shepherd Dog Laekenois",
	"Belgian Shepherd Dog Malinois",
	"Belgian Shepherd Dog Tervueren",
	"Bernese Mountain Dog",
	"Bichon Frise",
	"Bloodhound",
	"Border Collie",
	"Border Terrier",
	"Borzoi",
	"Boston Terrier",
	"Bouvier des Flandres",
	"Boxer",
	"Bracco Italiano",
	"Briard",
	"Brittany",
	"Bull Terrier",
	"Bull Terrier Miniature",
	"Bulldog",
	"Bullmastiff",
	"Cairn Terrier",
	"Cavalier King Charles Spaniel",
	"Cesky Terrier",
	"Chesapeake Bay Retriever",
	"Chihuahua (Smooth Coat)",
	"Chinese Crested",
	"Chow Chow (Smooth)",
	"Clumber Spaniel",
	"Collie (Rough)",
	"Collie (Smooth)",
	"Curly-Coated Retriever",
	"Dachshund (Miniature Long Haired)",
	"Dachshund (Miniature Smooth Haired)",
	"Dachshund (Miniature Wire Haired)",
	"Dachshund (Smooth Haired)",
	"Dachshund (Wire Haired)",
	"Dalmatian",
	"Dandie Dinmont Terrier",
	"Deerhound",
	"Dobermann",
	"Dogue de Bordeaux",
	"English Setter",
	"English Springer Spaniel",
	"English Toy Terrier (Black & Tan)",
	"Field Spaniel",
	"Finnish Lapphund",
	"Finnish Spitz",
	"Flat-Coated Retriever",
	"Fox Terrier Smooth Coat",
	"Fox Terrier Wire Coat",
	"Foxhound",
	"French Bulldog",
	"German Shepherd Dog",
	"German Short-Haired Pointer",
	"German Spitz Klein",
	"German Wire-Haired Pointer",
	"Golden Retriever",
	"Gordon Setter",
	"Great Dane",
	"Greyhound",
	"Harrier Hound",
	"Hungarian Vizsla",
	"Hungarian Wire-Haired Vizsla",
	"Ibizan Hound",
	"Irish Setter",
	"Irish Terrier",
	"Irish Water Spaniel",
	"Irish Wolfhound",
	"Italian Greyhound",
	"Japanese Akita",
	"Japanese Chin",
	"Japanese Spitz",
	"Keeshond",
	"Kerry Blue Terrier",
	"King Charles Spaniel",
	"Labrador Retriever",
	"Lakeland Terrier",
	"Leonberger",
	"Lhaso Apso",
	"Lowchen",
	"Maltese",
	"Manchester Terrier",
	"Maremma Sheepdog",
	"Mastiff",
	"Newfoundland",
	"Norfolk Terrier",
	"Norwich Terrier",
	"Nova Scotia Duck Tolling Retriever",
	"Old English Sheepdog",
	"Papillon",
	"Parson Jack Russell Terrier",
	"Pharaoh Hound",
	"Pointer",
	"Pomeranian",
	"Poodle Miniature",
	"Poodle Standard",
	"Poodle Toy",
	"Portuguese Water Dog",
	"Pug",
	"Pyrenean Mountain Dog",
	"Rhodesian Ridgeback",
	"Rottweiler",
	"Saluki",
	"Samoyed",
	"Schipperke",
	"Schnauzer Giant",
	"Schnauzer Miniature",
	"Schnauzer Standard",
	"Scottish Terrier",
	"Shar Pei",
	"Shetland Sheepdog",
	"Shih Tzu",
	"Siberian Husky",
	"Skye Terrier",
	"Sloughi",
	"Soft Coated Wheaten Terrier",
	"St Bernard",
	"Sussex Spaniel",
	"Swedish Vallhund",
	"Tenterfield Terrier",
	"Tibetan Mastiff",
	"Tibetan Spaniel",
	"Tibetan Terrier",
	"Weimaraner",
	"Welsh Corgi (Cardigan)",
	"Welsh Corgi (Pembroke)",
	"Welsh Springer Spaniel",
	"Welsh Terrier",
	"West Highland White Terrier",
	"Whippet",
	"Yorkshire Terrier",
}
